/* eslint valid-jsdoc: "off" */

"use strict";

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = (appInfo) => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = (exports = {});

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + "_1603164725243_7578";

  // add your middleware config here
  config.middleware = [];

  config.security = {
    csrf: false,
  };

  config.multipart = {
    // 启用 file 模式：
    mode: "file",
    fileSize: "50mb",
    fileExtensions: [".txt"], // 增加对 txt 扩展名的文件支持
  };

  // oss存储
  config.oss = {
    // 这里需要的东西去自己的服务器里看，我用的阿里云
    client: {
      accessKeyId: "LTAI4G9rBrgQoece24yvheD9",
      accessKeySecret: "Y670tVR56xA6sNRzjFfb7mLTd0gjsC",
      bucket: "hcaa-static",
      endpoint: "oss-cn-hangzhou.aliyuncs.com",
      timeout: "60s",
    },
  };

  // swagger文档配置
  config.swaggerdoc = {
    dirScanner: "./app/controller", //插件扫描的文档路径
    apiInfo: {
      title: "swagger文档",
      description: "egg.js swagger-demo文档",
      version: "1.0.0",
    },
    consumes: ["application/json", "multipart/form-data"], // 指定处理请求的提交内容类型（Content-Type），例如application/json, text/html
    produces: ["application/json", "multipart/form-data"], // 指定返回的内容类型，仅当request请求头中的(Accept)类型中包含该指定类型才返回
    schemes: ["http", "https"],
    routerMap: true, // 是否自动生成route
    enable: true,
  };

  config.mysql = {
    // 单数据库信息配置
    client: {
      // host
      host: "localhost",
      // 端口号
      port: "3306",
      // 用户名
      user: "root",
      // 密码
      password: "ccxx",
      // 数据库名
      database: "egg",
    },
    // 是否加载到 app 上，默认开启
    app: true,
    // 是否加载到 agent 上，默认关闭
    agent: false,
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };

  return {
    ...config,
    ...userConfig,
  };
};
